package cn.jltx.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import cn.jltx.javajni.IDataProvider;
import cn.jltx.ndkpassdata.R;


public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    private TextView textView;
    private Button btn1;
    private Button btn2;
    private Button btn3;
    private Button btn4;
    private IDataProvider provider;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView= (TextView)findViewById(R.id.tv);
        textView.setText("结果显示");

        btn1 = (Button)findViewById(R.id.btn1);
        btn1.setOnClickListener(this);

        btn2 = (Button)findViewById(R.id.btn2);
        btn2.setOnClickListener(this);

        btn3 = (Button)findViewById(R.id.btn3);
        btn3.setOnClickListener(this);

        btn4 = (Button)findViewById(R.id.btn4);
        btn4.setOnClickListener(this);

        provider = new IDataProvider();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn1:
                textView.setText(provider.add(10,52) + "");
                break;
            case R.id.btn2:
                textView.setText(provider.sayHelloInC("你好！"));
                break;
            case R.id.btn3:
                int[] arr = {1,2,3,4,5};
                provider.intMethod(arr);
                for (int i=0; i < arr.length; i++){
                    System.out.println("java=>"+arr[i]);
                }
                break;
            case R.id.btn4:
                int[][] ary = provider.getTwoArray(5);
                for (int i=0; i < ary.length; i++){
                    int[] ar = ary[i];
                    for (int j=0; j < ar.length; j++){
                        System.out.println("java=>"+ar[j]);
                        System.out.println("\t");
                    }
                }
                break;
            default:
                break;
        }
    }
}
